home *** CD-ROM | disk | FTP | other *** search
/ Windows 98 Secrets / Windows 98 Secrets Gold - Disc 1.iso / tools / textedit / winedit / winedit.mn_ / winedit.mn
Text File  |  1997-03-17  |  32KB  |  955 lines

  1. ;WINEDIT.MNU file.
  2. ;
  3. ;Modifications courtesy of Don Lekei, Richard Merit, Morrie Wilson
  4. ; and many many others.  Thank you very much.
  5. ;
  6. ; Some functions, like version control and alternate grep commands, 
  7. ; are presented here but commented out.  If you have the corresponding
  8. ; utility, just delete the semicolons from column 1 and the function
  9. ; will be enabled.
  10. ;
  11. ;
  12. ;
  13. ; AutoExec Section is on top here.
  14. ;
  15.         TAB=@TAB
  16.         CR=@CRLF
  17.         EOL=@CR
  18.         Home=DirHome()
  19.         IntControl(29,@tab,0,0,0)  ;Standardize on tabs as delimiters for FileItemize, etc
  20.         ;wDelButton(15,0)  ; for uncomment for 640x480 toolbar
  21.         
  22. Edit Utility Menu   ; Manage WinEdit Utility menu and help files
  23.         TheFile=strcat(DirHome(),"WINEDIT.MNU")
  24.         WFileOpen(TheFile)
  25.         Drop(TheFile)
  26. ;
  27. Edit Macro Menu   ; Manage WinEdit Macro menu
  28.         ; In the lite and standard versions of WinEdit,
  29.         ; the MACRO.ENC file is not editable.
  30.         ; In the Pro version, the file MACRO.MNU is used
  31.         ; and it can be edited.
  32.         level=2
  33.         a = FileLocate("WINEDIT.INI")
  34.         if FileExist(a) then level=IniReadPvt("WINEDIT","LEVEL","2",a)
  35.         if (level < 2) then Message("Edit Macro Menu","The Macro Menu cannot be edited in the Lite or Standard versions of WinEdit")
  36.         if (level < 2) then exit
  37.         ; else we can edit it
  38.         TheFile=strcat(DirHome(),"MACRO.MNU")
  39.         WFileOpen(TheFile)
  40.         Drop(TheFile)
  41.  
  42.  
  43. _Key Word Help      \ +{F1}         ; Load help topic for word at cursor
  44.         call(strcat(DirHome(),"wwwedit.dll"),"KEYWORDHELP")
  45.  
  46. Load Help File                    ; Load a help file (no keyword lookup)
  47.         TheFile=strcat(DirHome(),"HELP\WEHELP.INI")
  48.         Keys=IniItemizePvt("HelpAll",TheFile)
  49.         KeyMax=ItemCount(Keys,@TAB)
  50.         KeyIndex=0
  51.         KeyValues=""
  52.  
  53.         :ieLoop
  54.         if KeyIndex==KeyMax then goto looped
  55.         KeyIndex=KeyIndex+1
  56.         ThisKey=ItemExtract(KeyIndex,Keys,@TAB)
  57.         if (stricmp(ThisKey,"DEFAULT")==0) then goto ieloop
  58.         ThisValue=IniReadPvt("HelpAll",ThisKey,"???",TheFile)
  59.         KeyValues=strcat(KeyValues,ThisValue,"|")
  60.         goto ieLoop
  61.         
  62.         :looped
  63.         a=ItemSelect("Select Help File",strlower(KeyValues),"|")
  64.         if a=="" then goto DONE
  65.         b = FileLocate(strcat(DirHome(),"HELP\%a%"))
  66.         if b=="" then b=FileLocate(a)
  67.         if b=="" then Message("Helpfile %a% not found","Edit %TheFile%%CR%[HelpAll] section to%CR%point to help file location%CR%or put helpfile on DOS path.")
  68.                  else WinHelp(b,"CONTENTS","")
  69.         :DONE
  70.         Drop(TheFile,Keys,KeyMax,KeyIndex,KeyValues,ThisKey,ThisValue,a,b)
  71. ;
  72.  
  73. ;
  74. HTML
  75.  Template
  76.         wEdInsString("<html>")
  77.         wEdNewLine()
  78.         wEdInsString("<head>")
  79.         wEdNewLine()
  80.         wEdInsString("<title>Title</title>")
  81.         wEdNewLine()
  82.         wEdInsString("</head>")
  83.         wEdNewLine()
  84.         wEdInsString("<body>")
  85.         wEdNewLine()
  86.         wEdInsString("</body>")
  87.         wEdNewLine()
  88.         wEdInsString("</html>")
  89.         wEdNewLine()
  90.  Unordered List        
  91.         wEdInsString("<ul>")
  92.         wEdNewLine()
  93.         wEdInsString("<li>")
  94.         wEdNewLine()
  95.         wEdInsString("<li>")
  96.         wEdNewLine()
  97.         wEdInsString("<li>")
  98.         wEdNewLine()
  99.         wEdInsString("</ul>")
  100.         wEdNewLine()
  101.  Ordered List        
  102.         wEdInsString("<ol>")
  103.         wEdNewLine()
  104.         wEdInsString("<li>")
  105.         wEdNewLine()
  106.         wEdInsString("<li>")
  107.         wEdNewLine()
  108.         wEdInsString("<li>")
  109.         wEdNewLine()
  110.         wEdInsString("</ol>")
  111.         wEdNewLine()
  112.  HTMLize special characters < && >
  113.         ;if isdefined(dest)
  114.         ;  if dest<>0 then binaryfree(dest)
  115.         ;endif
  116.         ;if isdefined(source)
  117.         ;  if source<>0 then binaryfree(source)
  118.         ;endif
  119.         fn = wGetFileName()
  120.         wWinClose ()
  121.         fs=Filesize(fn)+1
  122.         ;BinaryPoke(source,fs-1,' ')
  123.         source=BinaryAlloc(fs)
  124.         BinaryRead(source,fn)
  125.         DestSize= fs+(BinaryStrCnt(source,0,fs-1,'>')+BinaryStrCnt(source,0,fs-1,'<')+BinaryStrCnt(source,0,fs-1,'&'))*5+20
  126.         source=BinaryFree(source)
  127.         source=BinaryAlloc(DestSize+1)
  128.         BinaryRead(source,fn)
  129.         dest=BinaryAlloc(DestSize+1)
  130.         newname=strcat(filepath(fn),FileRoot(fn),".HTML")
  131. ;        debug(1)
  132.         Smark=0
  133.         Dmark=0
  134.         while 1    ; MUST do & first !!!!!!
  135.            offset=BinaryIndexNC(source,Smark,'&',@fwdscan)
  136.            if offset==0
  137.                if BinaryPeekStr(source,Smark,1)!='&' then break
  138.            endif
  139.            length=offset-Smark
  140.            BinaryCopy(dest,Dmark,source,Smark,length)
  141.            Smark=Smark+length+1
  142.            BinaryPokestr(dest,Dmark+length,'&')
  143.            Dmark=Dmark+length+5
  144.         endwhile
  145.         BinaryCopy(dest,BinaryEodGet(dest),source,Smark,BinaryEodGet(source)-Smark)
  146.         xxx=source
  147.         source=dest
  148.         dest=xxx
  149.         BinaryEODSet(dest,0)
  150.         
  151.         Smark=0
  152.         Dmark=0
  153.         while 1
  154.            offset=BinaryIndexNC(source,Smark,'<',@fwdscan)
  155.            if offset==0
  156.                if BinaryPeekStr(source,Smark,1)!='<' then break
  157.            endif
  158.            length=offset-Smark
  159.            BinaryCopy(dest,Dmark,source,Smark,length)
  160.            Smark=Smark+length+1
  161.            BinaryPokestr(dest,Dmark+length,'<')
  162.            Dmark=Dmark+length+4
  163.         endwhile
  164.         BinaryCopy(dest,BinaryEodGet(dest),source,Smark,BinaryEodGet(source)-Smark)
  165.         xxx=source
  166.         source=dest
  167.         dest=xxx
  168.         BinaryEODSet(dest,0)
  169.         
  170.         BinaryPokeStr(dest,0,'<pre>%@crlf%')
  171.         Smark=0
  172.         Dmark=7
  173.         while 1
  174.            offset=BinaryIndex(source,Smark,'>',@fwdscan)
  175.            if offset==0
  176.                if BinaryPeekStr(source,Smark,1)!='>' then break
  177.            endif
  178.            length=offset-Smark
  179.            BinaryCopy(dest,Dmark,source,Smark,length)
  180.            Smark=Smark+length+1
  181.            BinaryPokestr(dest,Dmark+length,'>')
  182.            Dmark=Dmark+length+4
  183.         endwhile
  184.         BinaryCopy(dest,Dmark,source,Smark,BinaryEodGet(source)-Smark)
  185.         BinaryPokeStr(dest,BinaryEodGet(dest),"%@crlf%</pre>%@crlf%")
  186.         BinaryWrite(dest,newname)
  187.         dest=binaryfree(dest)
  188.         source=BinaryFree(source)
  189.         wFileOpen(newname)
  190.  
  191. _Insert Block
  192.  If-Else
  193.      wEdNewLine()
  194.      wEdUpLine()
  195.      ; First determine if it is C or WIL
  196.      ;debug(1)
  197.      filext = strupper(FileExtension(wGetFileName()))
  198.      if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"   ; Its WIL
  199.         wEdInsString("if  xx == yy")
  200.         wEdNewLine()
  201.         wEdNewLine()
  202.         wEdInsString("else")
  203.         wEdNewLine()
  204.         wEdNewLine()
  205.         wEdInsString("endif")
  206.         wEdNewLine()
  207.         wEdUpLine()
  208.         wEdUpLine()
  209.         wEdUpLine()
  210.         wEdUpLine()
  211.      else  ;assume C
  212.         wEdInsString("if  ( xx == yy )")
  213.         wEdNewLine()
  214.         wEdInsString("   {")
  215.         wEdNewLine()
  216.         wEdNewLine()
  217.         wEdInsString("}")
  218.         wEdNewLine()
  219.         wEdLeft()
  220.         wEdLeft()
  221.         wEdLeft()
  222.         wEdInsString("else")
  223.         wEdNewLine()
  224.         wEdInsString("   {")
  225.         wEdNewLine()
  226.         wEdNewLine()
  227.         wEdInsString("}")
  228.         wEdNewLine()
  229.         wEdUpLine()
  230.         wEdUpLine()
  231.         wEdUpLine()
  232.         wEdUpLine()
  233.         wEdUpLine()
  234.         wEdUpLine()
  235.      endif
  236.      drop(s,filext)
  237.  Switch
  238.      wEdNewLine()
  239.      wEdUpLine()
  240.      filext = strupper(FileExtension(wGetFileName()))
  241.      if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"   ; Its WIL
  242.         wEdNewLine()
  243.         wEdUpLine()
  244.         wEdInsString("switch switchvar")
  245.         wEdNewLine()
  246.         wEdInsString("   case 1")
  247.         wEdNewLine()
  248.         wEdInsString("   break")
  249.         wEdNewLine()
  250.         wEdNewLine()
  251.         wEdLeft()
  252.         wEdLeft()
  253.         wEdLeft()
  254.         wEdInsString("case 2")
  255.         wEdNewLine()
  256.         wEdInsString("   break")
  257.         wEdNewLine()
  258.         wEdNewLine()
  259.         wEdLeft()
  260.         wEdLeft()
  261.         wEdLeft()
  262.         wEdInsString("case 3")
  263.         wEdNewLine()
  264.         wEdInsString("   break")
  265.         wEdNewLine()
  266.         wEdNewLine()
  267.         wEdLeft()
  268.         wEdLeft()
  269.         wEdLeft()
  270.         wEdLeft()
  271.         wEdLeft()
  272.         wEdLeft()
  273.         wEdInsString("endswitch")
  274.         wEdNewLine()
  275.         wEdUpLine()
  276.         wEdUpLine()
  277.         wEdUpLine()
  278.         wEdUpLine()
  279.         wEdUpLine()
  280.         wEdUpLine()
  281.         wEdUpLine()
  282.         wEdUpLine()
  283.         wEdUpLine()
  284.      else  ;assume C
  285.         wEdInsString("switch (swvar)")
  286.         wEdNewLine()
  287.         wEdInsString("   {")
  288.         wEdNewLine()
  289.         wEdInsString("case 1:")
  290.         wEdNewLine()
  291.         wEdInsString("   break;")
  292.         wEdNewLine()
  293.         wEdNewLine()
  294.         wEdLeft()
  295.         wEdLeft()
  296.         wEdLeft()
  297.         wEdInsString("case 2:")
  298.         wEdNewLine()
  299.         wEdInsString("   break;")
  300.         wEdNewLine()
  301.         wEdNewLine()
  302.         wEdLeft()
  303.         wEdLeft()
  304.         wEdLeft()
  305.         wEdInsString("case 3:")
  306.         wEdNewLine()
  307.         wEdInsString("   break;")
  308.         wEdNewLine()
  309.         wEdNewLine()
  310.         wEdLeft()
  311.         wEdLeft()
  312.         wEdLeft()
  313.         wEdLeft()
  314.         wEdLeft()
  315.         wEdLeft()
  316.         wEdInsString("   }")
  317.         wEdNewLine()
  318.         wEdUpLine()
  319.         wEdUpLine()
  320.         wEdUpLine()
  321.         wEdUpLine()
  322.         wEdUpLine()
  323.         wEdUpLine()
  324.         wEdUpLine()
  325.         wEdUpLine()
  326.         wEdUpLine()
  327.      endif
  328.      drop(s,filext)
  329.  While
  330.      wEdNewLine()
  331.      wEdUpLine()
  332.      filext = strupper(FileExtension(wGetFileName()))
  333.      if filext=="WBT" || filext=="WIL" || filext=="MNU"  || filext=="WEB"  ; Its WIL
  334.         wEdInsString("while xx == yy")
  335.         wEdNewLine()
  336.         wEdNewLine()
  337.         wEdInsString("endwhile")
  338.         wEdNewLine()
  339.         wEdUpLine()
  340.         wEdUpLine()
  341.      else  ;assume C
  342.         wEdInsString("while (xx == yy)")
  343.         wEdNewLine()
  344.         wEdInsString("   {")
  345.         wEdNewLine()
  346.         wEdNewLine()
  347.         wEdInsString("}")
  348.         wEdNewLine()
  349.         wEdUpLine()
  350.         wEdUpLine()
  351.      endif
  352.      drop(s,filext)
  353.  Comment block       \ +^B
  354.         filext = strupper(FileExtension(wGetFileName()))
  355.         if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"  then cmt=";" ; Its WIL
  356.               else cmt="//"
  357.         s=""
  358.         ;if wGetSelState() then
  359.         s=wEdGetWord()
  360.         clipput ("%cmt%***************************************************************************%CR%")
  361.         clipappend("%cmt%** %s%%CR%")
  362.         clipappend("%cmt%** %CR%")
  363.         clipappend("%cmt%** %CR%")
  364.         clipappend ("%cmt%***************************************************************************%CR%")
  365.         wEDgotocol(1) ;insert above current line
  366.         wedstartsel()
  367.         wedendsel()
  368.         wednewline()
  369.         wEDgotocol(1) ;insert above current line
  370.         Wedpaste()
  371.         weddownline()
  372.         weddownline()
  373.         wedend()
  374.         drop(s,filext,cmt)
  375. ;
  376. ;Builds a DETAILED comment block from the label under the cursor.
  377. ;
  378.  Comment SUPER block       \ ^!B
  379.         filext = strupper(FileExtension(wGetFileName()))
  380.         if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"  then cmt=";" ; Its WIL
  381.               else cmt="//"
  382.         s=""
  383.         ;if wGetSelState() then
  384.         s=wEdGetWord()
  385.         clipput ("%cmt%***************************************************************************%CR%")
  386.         clipappend("%cmt%** %s%%CR%")
  387.         clipappend("%cmt%** %CR%")
  388.         clipappend("%cmt%** %CR%")
  389.         clipappend("%cmt%** Inputs: %CR%")
  390.         clipappend("%cmt%** Outputs: %CR%")
  391.         clipappend("%cmt%** Preserves: %CR%")
  392.         clipappend("%cmt%** Corrupts: %CR%")
  393.         clipappend ("%cmt%***************************************************************************%CR%")
  394.         wEDgotocol(1) ;insert above current line
  395.         wedstartsel()
  396.         wedendsel()
  397.         wednewline()
  398.         wEDgotocol(1) ;insert above current line
  399.         Wedpaste()
  400.         weddownline()
  401.         weddownline()
  402.         wedend()
  403.         drop(s,filext,cmt)
  404. ;
  405. ;Merge File header comment file from disk
  406. ;
  407. ;Header Block    \ ^!H
  408. ;        Wedgotoline(1)
  409. ;        WedGotoCol(1)
  410. ;        wFileMerge("header")
  411.  
  412. ;
  413. ;Shells external process to produce fancy printout of a file
  414. ;         
  415. ;Hardcopy        \ ^H
  416. ;        n=wGetfilename()
  417. ;        cmd="-o=10 -l,l %n% > lpt1"
  418. ;        AskLine("Hardcopy","Enter hardcopy command:",cmd)
  419. ;        wRunCommand("DOSPRMPT.PIF /c hcopy %cmd%",@FALSE,@FALSE)
  420. ;        drop (n,cmd)
  421.  
  422. ;
  423. ;
  424. Language Support
  425.  Generate C Tags                   ; Index source files
  426.         ; uses the TAGS.EXE program to generate WINEDIT.MRK file
  427.         ; that the next function uses to look up function names
  428.         ; in your source
  429.         RunWait("TAGS.EXE","-om -tWINEDIT.MRK *.c")
  430.         Message("Tags","Processing complete")
  431.  
  432.  Go to tag                         ; Jump to function definition
  433.         ; looks up the current word in WINEDIT.MRK, loads the file,
  434.         ; and moves the cursor to the correct line
  435.         ;DEBUG(1)
  436.         goto START
  437.         :GETWORD
  438.         a = AskLine("Go to tag", "Enter function definition to jump to:", "")
  439.         strupper(a)
  440.         len = strlen(a)
  441.         if len==0 then goto NOWORD
  442.         goto START2
  443.         :START
  444.         a=WEdGetWord()
  445.         strupper(a)
  446.         len = strlen(a)
  447.         if len==0 then goto GETWORD
  448.         :START2
  449.         b=FileLocate("winedit.mrk")
  450.         WFileOpen(b)
  451.         WFind(a,@TRUE,@FALSE)
  452.         WEdHome()
  453.         WEdStartSel()
  454.         WEdEnd()
  455.         WEdEndSel()
  456.         WEdCopy()
  457.         WWinClose()
  458.         line=ClipGet()
  459.         line2=strupper(line)
  460.         c=StrIndex(line2,a,0,@FWDSCAN)
  461.         d=StrIndex(line2," ",c,@FWDSCAN)
  462.         e=StrIndex(line2,"(",d,@FWDSCAN)
  463.         filename=StrSub(line2,d,e-d)
  464.         lineno=StrSub(line2,e+1,strlen(line2)-e-1)
  465.         WFileOpen(filename)
  466.         WEdGoToLine(lineno)
  467.         WEdHome()
  468.         Drop(len,b,line,line2,c,d,e,filename,lineno)
  469.         :NOWORD
  470.         Drop(a)
  471. ;
  472.  
  473.  
  474. ;;;;;;;;;;;;;;;
  475. Grep    \      ^G             ; Run fgrep
  476.         a = "fgrep.com"
  477.         b = FileNameShort(FileLocate(strcat(DirHome(),a)))
  478.         if b=="" then b=FileLocate(a)
  479.         if b=="" then Message("Error","Fgrep utility not found.  You can download fgrep.com from our Web site http://www.windowware.com/wwwftp/wilson/fgrep.zip")
  480.                  then goto DONE
  481.         tee=FileNameShort(strcat(DirHome(),"tee.com"))
  482.         GrepWord = wEdGetWord()         ; Get Selected word if any
  483.         if GrepWord=="" then GrepWord="StringToSearchFor"
  484.         command = AskLine("Grep - Microsoft Compiler Style output"","Enter the grep options to run:","%GrepWord% *.c")
  485.         command=strcat(tee," ",b," -M ",command)
  486.         wRunCommand(command,@TRUE,@TRUE)
  487.         :DONE
  488.         Drop(command,GrepWord,a,b,tee);
  489.  
  490.  
  491.  
  492. ;Multifile grep command. Expects to find unix-compatable grep AND gres
  493. ;commands in the path!  It parses the result into an error file so that 
  494. ;next and previous error works 
  495. ;
  496.  
  497. ; Grep    \      ^G             ; Run fgrep
  498. ;        Tee=strcat(DirHome(),"tee.com")
  499. ;        Where=strlower(StrSub(dirget(),1,strlen(dirget())-1))
  500. ;        drv=StrSub(Where,1,2)
  501. ;        ext=strlower(fileExtension(wGetFilename()))
  502. ;        if (ext=="c"|ext=="h") then ext = "?"
  503. ;        GrepWord = wEdGetWord()         ; Get Selected word if any
  504. ;        command = GrepWord
  505. ;        command = AskLine("Grep (multifile)","Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter text to find: ","%GrepWord%")
  506. ;        wRunCommand("grep -n %command% %Where%\*.%ext%|gres '^(..[^:]*)(: )([0-9][0-9]*)(: )' '\1 \3 Error:'",@TRUE,@TRUE)
  507. ;        Drop(command,GrepWord,Tee,Where,drv)
  508. ;
  509.  
  510.  
  511. Convert Line Endings
  512.  Strip carrage returns (Unixize the file)
  513.         fn = wGetFileName()
  514.         fs=Filesize(fn)
  515.         errormode(@off)
  516.         LastError()
  517.         bb=BinaryAlloc(fs)
  518.         errormode(@Cancel)
  519.         err=LastError()
  520.         if err!=0 
  521.            message("File Too Large  Err %err%","Try a smaller file")
  522.            wFileOpen(fn)
  523.            exit
  524.         endif
  525.         BinaryRead(bb,fn)
  526.         oldname=strcat(FilePath(fn),FileRoot(fn),".BAK")
  527.         wWinClose ()
  528.         Mac=BinaryStrCnt(bb,0,fs-1,@LF)
  529.         If Mac==0
  530.            message ("No Linefeeds","This file can't be safely stripped")
  531.            wFileOpen(fn)
  532.            binaryfree(bb)
  533.            exit
  534.         endif
  535.         FileMove(fn,oldname,0) ; Make backup   
  536.         if binarypeek(bb,0)==13 then binarypokestr(bb,0," ")
  537.         q=0
  538.         while 1
  539.             q=BinaryIndex(bb,q,@CR,@fwdscan)
  540.             if q==0 then break
  541.             BinaryPokeStr(bb,q," ")
  542.         endwhile
  543.         BinaryWrite(bb,fn)
  544.         BinaryFree(bb)
  545.         wFileOpen(fn)
  546.  
  547.   
  548.  Replace LF with CR/LF  (DOSize the file)
  549.         ;if isdefined(dest)
  550.         ;  if dest<>0 then binaryfree(dest)
  551.         ;endif
  552.         ;if isdefined(source)
  553.         ;  if source<>0 then binaryfree(source)
  554.         ;endif
  555.         fn = wGetFileName()
  556.         fs=Filesize(fn)+1
  557.         errormode(@off)
  558.         LastError()
  559.         source=BinaryAlloc(fs)
  560.         errormode(@cancel)
  561.         err=LastError()
  562.         if err!=0
  563.            message("File Too Large Err# %err%","Try a smaller file")
  564.            wFileOpen(fn)
  565.            exit
  566.         endif
  567.         BinaryRead(source,fn)
  568.         BinaryPoke(source,fs-1,10)
  569.         DestSize= fs+BinaryStrCnt(source,0,fs-1,@LF)-1
  570.         dest=BinaryAlloc(DestSize+1)
  571.         oldname=strcat(filepath(fn),FileRoot(fn),".BAK")
  572.         wWinClose ()
  573.         Smark=0
  574.         Dmark=0
  575.         while 1
  576.            offset=BinaryIndex(source,Smark,@LF,@fwdscan)
  577.            if offset==0 then break
  578.            length=offset-Smark
  579.            BinaryCopy(dest,Dmark,source,Smark,length)
  580.            Smark=Smark+length+1
  581.            if BinaryPeek(source,offset-1)==13  then length=length-1
  582.            BinaryPokestr(dest,Dmark+length,@CRLF)
  583.            Dmark=Dmark+length+2
  584.         endwhile
  585.         filemove(fn,oldname,0)
  586.         BinaryWrite(dest,fn)
  587.         dest=binaryfree(dest)
  588.         source=BinaryFree(source)
  589.         wFileOpen(fn)
  590.  
  591. ;
  592. ;        
  593. ;Delete to end of word. A real, proper, sane one. Like the good old days!
  594. ;If the cursor is in/before text, the rest of the word will be deleted.
  595. ;If the cursor is in whitespace, the rest of the whitespace will be deleted
  596. ;If the cursor is at the end of line, the next line will be concatinated
  597. ;
  598. ;
  599. Delete to end of word   \ ^T
  600.         col = wgetcolno()             ;save current posn
  601.         wedend()
  602.         e = wgetcolno()               ;Find end of line
  603.         if col>=e then goto Dend      ;end of line -- do delete! (concat lines)
  604.         wedgotocol(col)               ;back where we started
  605.         c1=wgetchar()
  606.         wEdStartSel()
  607.         :loop
  608.         wedright()
  609.         if wgetcolno() < e then c=wgetchar()
  610.         else c=""
  611.         if !strcmp(c1," ") then if !strcmp(c," ") then goto loop
  612.         if strcmp(c1," ") then if strlen(c) then if strcmp(c,"!")>=0 then if ((strcmp(c,":")<0) || (strcmp(c,"?")>0)) then goto loop
  613.         wEdEndSel()
  614.         :Dend
  615.         wEdDelete()
  616.         drop(c)
  617. ;
  618.  
  619. ;Improved toggle-case macro for Winedit 3.1
  620. ;
  621.  
  622. Toggle case     \ ^Q
  623.         a = wGetSelState()
  624.         if a == 1 then goto selection
  625.         a = wGetChar()
  626.         if (a == StrLower(a)) then a = StrUpper(a)
  627.         else a = StrLower(a)
  628.         wEdDelete()
  629.         wEdInsString(a)
  630.         Drop(a)
  631.         exit
  632.         :selection
  633.         line = wGetLineNo()
  634.         col = wGetColNo()
  635.         wEdCut()
  636.         a=clipget()
  637.         if (a == StrLower(a)) then ClipPut(StrUpper(a))        
  638.         else ClipPut(StrLower(a))        
  639.         wEdPaste()
  640.         wEdStartSel()
  641.         wEdGotoLine(line)
  642.         wEdGotoCol(col)
  643.         wEdEndSel()
  644.         drop (a,line,col)
  645.         
  646. ; Open the file under the cursor or marked
  647. ;
  648. Open highlighted file    \ ^F       ; Open selected file
  649.         name = wEdGetWord()
  650.         length = strlen(name)
  651.         if length==0 then goto DONE
  652.         b = FileLocate(name)
  653.         if b == "" then Message("Open selected file","Cannot find %name%")
  654.         if b == "" then goto DONE
  655.         wFileOpen(b)
  656.         :DONE
  657.         drop(name,length,b)
  658. ;
  659.         
  660. ;
  661. ;Version Control for use with RCS
  662. ;
  663. ;&Version Control           ; RCS commands
  664. ;; Lock/get file (co -l)  \ ^!F
  665. ;;        opt2="-l"
  666. ;;        goto lgf2
  667. ; Get file (co)          \ ^!O  
  668. ;        opt2=""
  669. ;        :lgf2
  670. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  671. ;        drv=StrSub(Where,1,2)
  672. ;        b=wGetFileName()
  673. ;        if b==1 then b=""
  674. ;        if wGetSelState() then s=wEdGetWord()
  675. ;           else s=b
  676. ;        a = AskLine("RCS Checkout %opt2%", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file you want to lock:", s)
  677. ;        ParseData(a)
  678. ;        s=fileroot(param%param0%)
  679. ;        if s==fileroot(b) then wWinClose()
  680. ;           else if b!="" then if AskYesNo("%a% is not the active file.%CR% %CR%Close Files","Close all files before continuing?")==@YES then wWinCloseall()
  681. ;
  682. ;;OS/2 Version
  683. ;;        wRunCommand("%drv% |cd %Where%|wetee co %opt2% %a%",@FALSE,@TRUE)
  684. ;;        pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  685. ;;DOS/WIN Version
  686. ;        wRunCommand("%drv% |cd %Where%|wetee co %opt2% %a%",@TRUE,@TRUE)
  687. ;      
  688. ;         Wfileopen(b)
  689. ;        b=FileLocate(a)
  690. ;        if b=="" then goto NotFound
  691. ;          WFileOpen(b)
  692. ;          goto DONE
  693. ;        :NotFound
  694. ;          Message("Sorry", "%a% not found...")
  695. ;          goto Done
  696. ;        :DONE
  697. ;        Drop(a)
  698. ;        Drop(b,Where,drv,s)
  699. ;
  700. ; Checkin file (ci)     \ ^!I
  701. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  702. ;        drv=StrSub(Where,1,2)
  703. ;        b=wGetFileName()
  704. ;        if b==1 then b=""
  705. ;        if wGetSelState() then s=wEdGetWord()
  706. ;           else s=b
  707. ;        a = AskLine("RCS Checkin (unlock)", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file you want to put back:",s )
  708. ;        ParseData(a)
  709. ;        s=fileroot(param%param0%)
  710. ;        if s==fileroot(b) then wWinClose() 
  711. ;           else if AskYesNo("%a% is not the active file.%CR% %CR%Close Files","Close all files before continuing?")==@YES then wWinCloseall()
  712. ;        wRunCommand("%drv% |cd %Where%|wetee ci %a%",@TRUE,@TRUE)
  713. ;;(if OS/2)     pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  714. ;        wfileopen(b) ; reopen original window
  715. ;        Drop(a,Where,drv,b,s)
  716. ;
  717. ; Enter any command (clean)     \ ^!C
  718. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  719. ;        drv=StrSub(Where,1,2)
  720. ;        b=wGetFileName()
  721. ;        if b==1 then b=""
  722. ;        if wGetSelState() then s=wEdGetWord()
  723. ;           else s=strcat("rcsclean ",b)
  724. ;        a = AskLine("Any Command", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter command:", s)
  725. ;        ParseData(a)
  726. ;        s=fileroot(param%param0%)
  727. ;        if s==fileroot(b) then wWinClose()
  728. ;           else if AskYesNo("Close Files","%S% is not the active file.%CR% %CR%Close all files before continuing?")==@YES then wWinCloseall()
  729. ;        wRunCommand("%drv% |cd %Where%|%a%",@TRUE,@TRUE)
  730. ;;if OS/2        pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  731. ;        wfileopen(b)
  732. ;        Drop(a,b,s,Where,drv)
  733. ;
  734. ;; &Logfile Info (locked)
  735. ;;        a = AskLine("PVCS Logfile Command", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file for which you want logfile info:", "")
  736. ;;        a=strcat("tee vlog -BL ",a)
  737. ;;        wRunCommand(a,@TRUE,@TRUE)
  738. ;;        Drop(a,Where,drv)
  739. ;
  740. ;; &Update all source files
  741. ;;        wRunCommand("tee get -u *.??v",@TRUE,@TRUE)
  742. ;
  743. ;
  744. ;&Version Control          ; PVCS commands
  745. ; &Get a file (w/lock)
  746. ;        a = AskLine("PVCS Get (w/lock) Command", "Enter file you want to lock:", "")
  747. ;        b=strcat("tee get -L ",a)
  748. ;        wRunCommand(b,@TRUE,@TRUE)
  749. ;        Drop(b)
  750. ;        b=FileLocate(a)
  751. ;        if b=="" then goto NotFound
  752. ;          WFileOpen(b)
  753. ;          goto DONE
  754. ;        :NotFound
  755. ;          Message("???", "%a% not found...")
  756. ;          goto Done
  757. ;        :DONE
  758. ;        Drop(a)
  759. ;        Drop(b)
  760. ;
  761. ; &Put a file back (unlock)
  762. ;        a = AskLine("PVCS Put (unlock) Command", "Enter file you want to put back:", "")
  763. ;        a=strcat("tee put ",a)
  764. ;        wRunCommand(a,@TRUE,@TRUE)
  765. ;        Drop(a)
  766. ;
  767. ; &Enter any PVCS command
  768. ;        a = AskLine("PVCS Command", "Enter PVCS command:", "")
  769. ;        a=strcat("tee ",a)
  770. ;        wRunCommand(a,@TRUE,@TRUE)
  771. ;        Drop(a)
  772. ;
  773. ; &Logfile Info (locked)
  774. ;        a = AskLine("PVCS Logfile Command", "Enter file for which you want logfile info:", "")
  775. ;        a=strcat("tee vlog -BL ",a)
  776. ;        wRunCommand(a,@TRUE,@TRUE)
  777. ;        Drop(a)
  778. ;
  779. ; &Update all source files
  780. ;        wRunCommand("tee get -u *.??v",@TRUE,@TRUE)
  781. ;
  782. ;;
  783.  
  784. _Utilities      ;      Select from list of utilities
  785.  &Freespace on Local Drives   ; Display free disk space on drives
  786.  
  787.         Drive=DiskScan(2)     ; 2 is the code for local hard drives
  788.         Dmax=strlen(Drive)
  789.         DIndex=1
  790.         TotalSize=0
  791.         DriveReport=""
  792.  
  793.         :COUNTSPACE
  794.         NextDrive=StrSub(Drive,Dindex,1)
  795.         a=DiskFree(NextDrive)/1024
  796.         TotalSize=a+TotalSize
  797.         DriveReport=strcat(DriveReport,NextDrive," = ",a,"K","@")
  798.         DIndex=Dindex+3  ;each entry is 3 bytes long
  799.         if DIndex<=Dmax then goto COUNTSPACE
  800.         ItemSelect("Total Space Available = %TotalSize%K",DriveReport,"@")
  801.         Drop(xxx,TotalSize,DriveReport,NextDrive,LastDrive)
  802.  
  803.  &Wallpaper                   ; Change the desktop wallpaper
  804.            DirChange(dirWindows(0))
  805.            a=FileItemize("*.BMP")
  806.            a=strcat("-None- ",a)
  807.            a=ItemSelect("Select New Wallpaper",a,@tab)
  808.            terminate(a=="","Wallpaper","No wallpaper selected")
  809.            if a=="-None-" then Wallpaper("",0)
  810.            if a=="-None-" then exit
  811.            tile=@FALSE
  812.            if FileSize(a)<40000 then tile=@TRUE  
  813.            ;if bmp size less than 40K, assume tile, else center
  814.            Wallpaper(a,tile)
  815.            drop(a,b,tile)
  816.         exit
  817.  
  818.  Paste Special Characters             ; Paste high ASCII characters to clipboard or document
  819.   Copy &FormFeed to Clipboard
  820.        Clipput(Num2char(12))
  821.   Copy &Special Characters to Document
  822.        a=" í| ó| ú| ñ| Ñ| ª| º| ¿| ⌐| ¬|"       ;161 thru 170
  823.        b=" ½| ¼| ¡| «| »| ░| ▒| ▓| │| ┤|"       ;171 thru 180
  824.        c=" ╡| ╢| ╖| ╕| ╣| ║| ╗| ╝| ╜| ╛|"       ;181 thru 190
  825.        d=" ┐| └| ┴| ┬| ├| ─| ┼| ╞| ╟| ╚|"       ;191 thru 200
  826.        e=" ╔| ╩| ╦| ╠| ═| ╬| ╧| ╨| ╤| ╥|"       ;201 thru 210
  827.        f=" ╙| ╘| ╒| ╓| ╫| ╪| ┘| ┌| █| ▄|"       ;211 thru 220
  828.        g=" ▌| ▐| ▀| α| ß| Γ| π| Σ| σ| µ|"       ;221 thru 230
  829.        h=" τ| Φ| Θ| Ω| δ| ∞| φ| ε| ∩| ≡|"       ;231 thru 240
  830.        i=" ±| ≥| ≤| ⌠| ⌡| ÷| ≈| °| ∙| ·|"       ;241 thru 250
  831.        j=" √| ⁿ| ²| ■|  "                       ;251 thru 255
  832.        a=strcat(a,b,c,d,e,f,g,h,i,j)
  833.        Drop(b,c,d,e,f,g,h,i,j)
  834.        a=ItemSelect("Choose a character",a,"|")
  835.        a=strsub(a,2,1)
  836.        wEdInsString(a)
  837.        Drop(a)
  838.  
  839.  
  840. &System Information
  841.        wintype="retail"
  842.        if WinMetrics(22) then wintype="debug"
  843.         wcx=WinMetrics(-3)
  844.         math="Math"
  845.         switch wcx
  846.            case 0   ; Win16
  847.                 wc=WinConfig()
  848.                 if !(wc&1) then mode="Real"
  849.                 if wc&16 then mode="Standard"
  850.                 if wc&32 then mode="Enhanced"
  851.                 
  852.                 if wc&64 then cpu=8086
  853.                 if wc&128 then cpu=80186
  854.                 if wc&2 then cpu=286
  855.                 if wc&4 then cpu=386
  856.                 if wc&8 then cpu=486
  857.                 mode = strcat(mode,' ',wintype,' Windows ')
  858.                 if !(wc&1024)  then math="No math"
  859.                 break
  860.           case 1 ; Win32 Intel
  861.                mode="Intel 32-bit %wintype% Windows "
  862.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  863.                break
  864.           case 2 ; Dec Alpha
  865.                mode="DEC Alpha %wintype% Windows NT "
  866.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  867.                break
  868.           case 3 ; MIPS
  869.                mode="MIPS %wintype% Windows NT "
  870.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  871.                break
  872.           case 4 ; PowerPC 
  873.                mode="PowerPC %wintype% Windows NT "
  874.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  875.                break
  876.           case wcx
  877.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  878.                mode="Unknown platform %wintype% Windows  "
  879.         endswitch
  880.  
  881.         Sysinfo=strcat(cpu,' ',mode,WinVersion(1),'.',WinVersion(0),@CRLF)
  882.  
  883.         mouse="No Mouse"
  884.         if WinMetrics(19) then mouse="Mouse"
  885.  
  886.         Sysinfo=strcat(sysinfo,math," co-processor.   ",mouse,' available.',@CRLF)
  887.  
  888.         sysinfo=strcat(sysinfo,WinMetrics(0),'x',WinMetrics(1)," video resolution.  ",WinMetrics(-1),"  colors.",@CRLF)
  889.  
  890.         ErrorMode(@OFF)
  891.         LastError()
  892.         PlayMedia("Status WaveForm Ready")
  893.         ErrorMode(@CANCEL)
  894.         if LastError()!=1193 then sysinfo=strcat(sysinfo,"Windows multimedia extensions present.",@CRLF)
  895.         a=NetInfo(0)
  896.         if a=="MULTINET"
  897.              b=NetInfo(1)
  898.              bug=strcat(b,"network(s) installed")
  899.              ;Message("Multinet supporting  %count% networks", b)
  900.         else
  901.              ;Message("Installed Network", a)
  902.              bug=strcat(a," network installed")
  903.         endif
  904.         sysinfo=strcat(sysinfo,bug,@crlf)
  905.  
  906.  
  907.         switch wcx
  908.            case 0
  909.                bug=WinResources(0)/1024   ; Compute memory avail
  910.                math=strlen(bug)
  911.                if math>3 then bug=strcat(strsub(bug,1,math-3),',',strsub(bug,math-2,3))
  912.                sysinfo=strcat(sysinfo,CR,bug," KB Free Memory",CR)
  913.                sysinfo=strcat(sysinfo,WinResources(2),"%% System Resources Free (",WinResources(3),"%% GDI, ",WinResources(4),"%% User)",CR)
  914.               break
  915.            case wcx
  916.               bug=WinResources(11)/1024   ; Get Physical memory avail
  917.               sysinfo=strcat(sysinfo,CR,bug," KB Physical Memory",CR)
  918.               bug=(WinResources(14)/1024)+bug   ; Get Virtual memory + Physical avail
  919.               sysinfo=strcat(sysinfo,bug," KB Total Memory",CR)
  920.         end switch
  921.  
  922.  
  923.         sysinfo=strcat(sysinfo,"Console ",DosVersion(1),'.',DosVersion(0),"  using ",environment("COMSPEC"),@CRLF)
  924.         disks=DiskScan(1)
  925.         disks=StrReplace(disks,@tab," ")
  926.         if disks!="" then sysinfo=strcat(sysinfo,"Floppies ",disks,@CRLF)
  927.         disks=DiskScan(2)
  928.         disks=StrReplace(disks,@tab," ")
  929.         if disks!="" then sysinfo=strcat(sysinfo,"Hard Disks ",disks,@CRLF)
  930.         disks=DiskScan(4)
  931.         disks=StrReplace(disks,@tab," ")
  932.         if disks!="" then sysinfo=strcat(sysinfo,"Network Disks ",disks,@CRLF)
  933.         sysinfo=strcat(sysinfo,"Windows Directory ",DirWindows(0),@CRLF)
  934.         sysinfo=strcat(sysinfo,"System  Directory ",DirWindows(1),@CRLF)
  935.         sysinfo=strcat(sysinfo,@CRLF,"WIL Interpreter Ver ",VersionDll())
  936.  
  937.         ver=Version()
  938.         Message("%Param2% %ver% SysInfo",Sysinfo)
  939.         Exit
  940.  
  941. Interactive Execution
  942.           if !IsDefined(uyit65) then uyit65="Message( , )"
  943.           :NEXT
  944.           uyit65=AskLine("Interactive Execution","Enter Command",uyit65)
  945.           execute %uyit65%
  946.           goto NEXT
  947.           
  948. _Run a WIL Script File
  949.          if wGetModified()==@TRUE then wFileSave()
  950.          TheFile = WGetFileName()
  951.          Call(TheFile,"")
  952.  
  953.         
  954.